<template>
  <div>
    <p>时间：{{time|timeFormate('-')}}</p>
    <p>时间：{{time|timeFormate('/')}}</p>
  </div>
</template>

<script>
export default {
  data () {
    return {
      time: 1636459422736
    }
  },
  filters: {
    timeFormate (val, str) {
      const date = new Date(val)
      const y = date.getFullYear()
      const m = (date.getMonth() + 1).toString().padStart(2, '0')
      const d = (date.getDate()).toString().padStart(2, '0')
      return `${y}${str}${m}${str}${d}`
    }
  }
}
</script>

<style>

</style>
